define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'kuozhan/jihua/index' + location.search,
                    add_url: 'kuozhan/jihua/add',
                    edit_url: 'kuozhan/jihua/edit',
                    del_url: 'kuozhan/jihua/del',
                    multi_url: 'kuozhan/jihua/multi',
                    import_url: 'kuozhan/jihua/import',
                    table: 'kuozhan_jihua',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                // pk: 'id',
                // sortName: 'weigh',
                // fixedColumns: true,
                 fixedRightNumber: 1,
                pk: 'id',
                sortName: 'weigh',
                sortOrder: "desc",
                search: false,
                commonSearch: true,
                showExport: false,
                showToggle: false,
                showSearchButton: true,
                searchFormVisible: true,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'peixun', title: __('Peixun'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'qi', title: __('Qi'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'xingshi', title: __('Xingshi'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'zhizhi', title: __('Zhizhi'), searchList: {"有":__('有'),"无":__('无')}, formatter: Table.api.formatter.normal},
                        {field: 'zhizhi_quyu', title: __('Zhizhi_quyu'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'weigh', title: __('Weigh'), operate: false},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
